using System.Collections;
using System.Collections.Generic;
using System.Threading;
using Castle.Core.Logging;
using CS2.Core.Logging;

namespace CS2.Core
{
    public class LoggedSynchronizedStringSet : ISynchronizedStringSet, ILoggingService
    {
        mutable inner : ISynchronizedStringSet;
        mutable logger : ILogger = NullLogger.Instance;

        public this(inner : ISynchronizedStringSet)
        {
            this.inner = inner;
        }

        public Logger : ILogger 
        {
            get { logger; }
            set { logger = value; }
        }

        public GetEnumerator() : IEnumerator[string]
        {
            inner.GetEnumerator();
        }

        public Add(item : string) : bool
        {
            Logger.InfoFormat("Adding {0} to collection. Total items: {1}", item, Count);
            inner.Add(item);
        }

        public Clear() : void
        {
            Logger.InfoFormat("Clearing collection");
            inner.Clear();
        }

        public CloneAndClear() : ISynchronizedStringSet
        {
            Logger.InfoFormat("Cloning and clearing the collection. Total items: {0}", Count);
            inner.CloneAndClear();
        }

        public Remove(item : string) : bool
        {
            Logger.InfoFormat("Removing {0} from the collection. Total items: {1}", item, Count);
            inner.Remove(item);
        }

        public Count : int
        {
            get { inner.Count; }
        }
    }
}